<%--
  Created by IntelliJ IDEA.
  User: 罗蔚
  Date: 2022/4/4
  Time: 18:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>展式所有用户信息</title>

    <link rel="stylesheet" href="../font-awesome-4.7.0/css/font-awesome.min.css">
    <script src="../js/jquery-3.6.0.min.js"></script>
    <style type="text/css">
        div{
            width: 1053px;
            margin: auto;
            text-align: center;
        }
        table{
            margin: auto;
        }
    </style>
</head>
<body>
<div id="">
    <table border="" cellspacing="0" cellpadding="30px" id="tab">
        <caption>用户表</caption>
        <tr>
            <th>id</th>
            <th>用户名</th>
            <th>密码</th>
            <th>邮箱</th>
            <th>头像</th>
            <th>状态</th>
            <th>激活码</th>
        </tr>
    </table>
</div>
</body>
<script>
    //发送ajax,获取所有的用户信息
    $.ajax({
        type:"get",
        url:"${pageContext.request.contextPath}/loginController/show",
        contentType:"application/json",
        data:"",
        dataType:"json",
        success:function(data){
            //将str添加到里面的后面
            var str = "";
            //console.log(data)
            if(data.code == 500){
                alert("用户为空")
            }else{
                //console.log(data.data)
                for(var i = 0; i < data.data.length; i++){
                    //console.log(data.data[i])
                    str += '<tr><td>'+data.data[i].id+'</td>'+
                            '<td>'+data.data[i].username+'</td>'+
                            '<td>'+data.data[i].password+'</td>'+
                            '<td>'+data.data[i].email+'</td>'+
                            '<td>'+data.data[i].image+'</td>'+
                            '<td>'+data.data[i].status+'</td>'+
                            '<td>'+data.data[i].code+'</td></tr>';
                }
            }

            $("table").append(str);
        }
    })
</script>
</html>
